package com.earthchen.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.earthchen.dao.MattressMapper;
import com.earthchen.domain.entity.sensor.Mattress;
import com.earthchen.domain.dto.MattressDTO;
import com.earthchen.service.MattressService;
import org.springframework.beans.BeanUtils;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.util.Arrays;

/**
 * 床垫服务实现类
 *
 * @author earthchen
 * @date 2018/10/28
 **/
@Service
public class MattressServiceImpl extends ServiceImpl<MattressMapper, Mattress> implements MattressService {

    @Async(value = "saveDataThreadPool")
    @Override
    public void syncMqttToDb(MattressDTO mattressDTO) {
        Mattress mattress = new Mattress();
        BeanUtils.copyProperties(mattressDTO, mattress);
        mattress.setPosition(Arrays.toString(mattressDTO.getPosition()));
        save(mattress);
    }
}
